<?php

use wap\assets\PageAsset;
use wap\models\Cases;
use yii\widgets\LinkPager;

/* @var $this yii\web\View */
/* @var $data \wap\models\Cases[] */

$this->title = 'Biffar Case';

PageAsset::register($this)->init([
    'css' => [
        'css/case.css',
    ],
]);
?>

<div class="page-body">
    <div class="topbar" style="background-image: url('img/inner-page/case.jpg')"></div>

    <div class="box partner-box">
        <div class="container">
            <div class="box-text">
                <h3>Our Partners</h3>
                <div class="split-line"></div>
                <p>部分合作伙伴</p>
            </div>

            <div class="box-body">
                <ul>
                    <li><a href=""><img src="tmp/link-01.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-02.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-03.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-04.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-05.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-06.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-07.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-08.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-09.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-10.jpg" /></a></li>
                    <li><a href=""><img src="tmp/link-11.jpg"/></a></li>
                    <li><a href=""><img src="tmp/link-12.jpg"/></a></li>
                </ul>
            </div>
        </div>
    </div>

    <div class="container clearfix">
        <div class="sidebar">
            <h1>Case</h1>
            <h3>Biffar工程案例</h3>

            <div class="siderbar-nav">
                <ul>
                    <li><a href="<?= \yii\helpers\Url::to(['case/index']) ?>">全部</a></li>
                    <?php $navs = Cases::getNavs() ?>
                    <?php foreach($navs as $nav){ ?>
                        <li>
                            <?php if(isset($nav['childs'])){ ?>
                                <a class="nav-item" href="javascript:;"><?= $nav['name'] ?><span class="iconfont <?= $nav['active'] ? 'icon-minus' : 'icon-plus' ?>"></span></a>

                                <ul style="display: <?= $nav['active'] ? 'block' : 'none' ?>">
                                    <?php foreach($nav['childs'] as $child){ ?>
                                        <li class="<?= $child['active'] ?>"><a href="<?= $child['url'] ?>"><?= $child['name'] ?></a></li>
                                    <?php } ?>
                                </ul>
                            <?php }else{ ?>
                            <a href="<?= $nav['url'] ?>"><?= $nav['name'] ?></a>
                            <?php } ?>
                        </li>
                    <?php } ?>
                </ul>
            </div>
        </div>

        <div class="case-list">
            <ul>
                <?php foreach($data as $datum){ ?>
                    <li>
                        <a href="<?= $datum->getViewUrl() ?>" class="preview"><img src="<?= $datum->getPreviewUrl(264, 170) ?>" /></a>
                        <h3><?= $datum->name ?></h3>
                        <p>开发商：<?= $datum->developer ?></p>
                    </li>
                <?php } ?>
            </ul>
        </div>

        <div class="pager">
            <?= LinkPager::widget(['pagination' => $pager]) ?>
        </div>
    </div>
</div>

<?php

$js = <<<JS

$('.siderbar-nav .nav-item').click(function(){
    var navItem = $(this);
    var subNav = navItem.next('ul');
    
    if(subNav.is(":hidden")){
        navItem.children('span').removeClass('icon-plus').addClass('icon-minus');
        subNav.slideDown();
    }else{
        navItem.children('span').removeClass('icon-minus').addClass('icon-plus');
        subNav.slideUp();
    }
});

JS;

$this->registerJs($js);
